package cn.edu.tju.cas.util;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by catold on 16/4/21.
 */
public class PassedTicket {
    private static volatile PassedTicket passedTicket;

    private List<String> tickets;

    private PassedTicket() {
        tickets = new ArrayList<String>();
    }

    public static PassedTicket getInstance(){
        if(passedTicket == null){
            synchronized (PassedTicket.class){
                if(passedTicket == null) {
                    passedTicket = new PassedTicket();
                }
            }
        }
        return passedTicket;
    }

    public boolean removeTicket(String ticket){
        return tickets.remove(ticket);
    }

    public void addTicket(String ticket){
        tickets.add(ticket);
    }

    public boolean containTicket(String ticket){
        return tickets.contains(ticket);
    }
}
